package com.thinkTank.oa.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.thinkTank.oa.common.Constant;
import com.thinkTank.oa.entity.Person;
import com.thinkTank.oa.lucene.IsolrOperation;
import com.thinkTank.oa.lucene.LuceneCustomer;
import com.thinkTank.oa.lucene.LuceneDemand;
import com.thinkTank.oa.lucene.LucenePerson;
import com.thinkTank.oa.lucene.LuceneProject;
import com.thinkTank.oa.lucene.Pagination;
import com.thinkTank.oa.lucene.SolrOperation;
import com.thinkTank.oa.service.CustomerService;
import com.thinkTank.oa.service.DemandService;
import com.thinkTank.oa.service.PersonService;
import com.thinkTank.oa.service.ProjectService;
import com.thinkTank.oa.util.Json;

/***
 * 索引管理类
 * @date 2018-09-13
 * @author dq
 *
 */
@Controller
@RequestMapping("lucene")
public class LuceneController  extends BaseController{
	private final static Logger logger = LoggerFactory.getLogger(LuceneController.class);
	
	@Autowired
	private ProjectService projectService;
	@Autowired
	private PersonService personService;
	@Autowired
	private CustomerService customerService;
	@Autowired
	private DemandService demandService; 
	@RequestMapping("showAllIndex")
	public String  showAllIndex(){
		
		return null;
	}

	/****
	 * @date 2018-10-23
	 * @author dq
	 * 根据提交查询索引数据
	 * @param searchType 查询对象 
	 * @param  keyWords 查新内容
	 * @return
	 */
	@RequestMapping("luceneSearch")
	public String luceneSearch(Model model,Integer pageNo,Integer searchType,String keyWords){
		try{
			if(pageNo==null)pageNo=1;
			if(searchType==null){
				searchType=1;
				
				IsolrOperation<LucenePerson> sop = new SolrOperation<LucenePerson>();
				Pagination pagination = sop.luceneSearch(pageNo, 10, searchType, keyWords);
				 model.addAttribute("pageInfo", pagination);
				 model.addAttribute("keyWords", keyWords);
			}
		}catch(Exception e){
			
		}
		return "luceneSearch";
	}
	private LucenePerson lucenePersonConversion(Person person){
		LucenePerson lp = new LucenePerson();
		try{
			String expertId = person.getPid();
			if(expertId!=null&&!"".equals(expertId)){
				lp.setExpertId(expertId);
			}
			Integer expertNumber = person.getExpertNumber();
			if(expertNumber!=null&&expertNumber>0){
				lp.setExpertNumber("E"+expertNumber);
			}
			Integer source = person.getSource();
			if(source!=null&&source>0){
				lp.setSource(getDicSingleWorth(person.getSource(), Constant.DICTIONTRY_PROJECTSOURCE));
			}
			Integer type = person.getType();
			if(type!=null && type>0){
				lp.setType(getDicSingleWorth(person.getType(), Constant.DICTIONTRY_PERSONTYPE));
			}
			String researchField = person.getResearchField();
			if(researchField!=null &&!"".equals(researchField)){
				researchField = getDicCheckboxWorth(person.getResearchField(), Constant.DICTIONTRY_PROJECTFIELD);
				String[] arr  = researchField.split(",");
				List<String> list = new ArrayList<String>();
				for(String t :arr){
					list.add(t);
				}
				lp.setResearchField(list);
			}
			String	area =person.getArea();
			if(area!=null&&!"".equals(area)){
				lp.setArea(getAreaWorth(person.getArea(), person.getDomesticOrForeign()));
			}
			String	talentLevel =person.getTalentLevel();
			if(talentLevel!=null&&!"".equals(talentLevel)){
				talentLevel = getDicCheckboxWorth(person.getTalentLevel(), Constant.DICTIONTRY_TALENTLEVEL);
				String[] arr  = researchField.split(",");
				List<String> list = new ArrayList<String>();
				for(String t :arr){
					list.add(t);
				}
				lp.setTalentLevel(list);
			}
			
			String	name = person.getName();
			if(name!=null&&!"".equals(name)){
				lp.setName(name);
			}
			String	schoolAndMajor =person.getSchoolAndMajor();
			if(schoolAndMajor!=null&&!"".equals(schoolAndMajor)){
				lp.setSchoolAndMajor(schoolAndMajor);
			}
			String	unit = person.getUnit();
			if(unit!=null&&!"".equals(unit)){
				lp.setUnit(unit);
			}
			String	title = person.getTitle();
			if(title!=null&&!"".equals(title)){
				lp.setTitle(title);
			}
			String	professionaField =person.getProfessionaField();
			if(professionaField!=null&&!"".equals(professionaField)){
				lp.setProfessionaField(professionaField);
			}
			String	education =person.getEducation();
			if(education!=null&&!"".equals(education)){
				lp.setEducation(education);
			}
			String	workExp =person.getWorkExp();
			if(workExp!=null&&!"".equals(workExp)){
				lp.setWorkExp(workExp);
			}
			String	honorAward =person.getHonorAward();
			if(honorAward!=null&&!"".equals(honorAward)){
				lp.setHonorAward(honorAward);
			}
			String	technica = person.getTechnica();
			if(technica!=null&&!"".equals(technica)){
				lp.setTechnica(technica);
			}
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
		return lp;
	}
	private LuceneProject luceneProjectConversion(Map<Object,Object> projectInfo){
		LuceneProject luceneProject = new LuceneProject();
		try{
			String projectNumber = projectInfo.get("projectNumber")+"";
			if(null!=projectNumber&&!"".equals(projectNumber)){
				luceneProject.setProjectNumber("R"+projectNumber);
			}
			String projectId  = projectInfo.get("projectId")+"";
			if(null!=projectId && !"".equals(projectId)){
				luceneProject.setProjectId(projectId);
			}
			String source  = projectInfo.get("source")+"";
			if(null!=source && !"".equals(source)){
				luceneProject.setSource(getDicSingleWorth(Integer.parseInt(source), Constant.DICTIONTRY_PROJECTSOURCE));
			}
			String sourceRemark  = projectInfo.get("sourceRemark")+"";
			if(null!=sourceRemark && !"".equals(sourceRemark)){
				luceneProject.setSourceRemark(sourceRemark);
			}
			
			String projectType  = projectInfo.get("projectType")+"";
			if(null!=projectType && !"".equals(projectType)){
				projectType = getDicCheckboxWorth(projectType, Constant.DICTIONTRY_PROJECTTYPE);
				List<String> protype = new ArrayList<String>();
				String[]proArr = projectType.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				luceneProject.setProjectType(protype);
			}
			String researchField  =projectInfo.get("researchField")+"";
			if(null!=researchField && !"".equals(researchField)){
				researchField = getDicCheckboxWorth(researchField, Constant.DICTIONTRY_PROJECTFIELD);
				List<String> protype = new ArrayList<String>();
				String[]proArr = researchField.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				luceneProject.setResearchField(protype);
			}
			
			String area  =projectInfo.get("area")+"";
			String domesticOrForeign  = projectInfo.get("domesticOrForeign")+"";
			if(null!=area && !"".equals(area)){
				
				luceneProject.setArea(getAreaWorth(area, Integer.parseInt(domesticOrForeign)));
			}
			String projectName  = projectInfo.get("projectName")+"";
			
			if(null!=projectName && !"".equals(projectName)){
				
				luceneProject.setProjectName(projectName);
			}
			String projectStatus  = projectInfo.get("projectStatus")+"";
			if(null!=projectStatus && !"".equals(projectStatus)){
				
				luceneProject.setProjectStatus(getDicSingleWorth(Integer.parseInt(projectStatus), Constant.DICTIONTRY_PROJECTSTATUS));
			}
			String introduction  = projectInfo.get("introduction")+"";
			if(null!=introduction && !"".equals(introduction)){
				
				luceneProject.setIntroduction(introduction);
			}
			String keyWords  = projectInfo.get("keyWords")+"";
			if(null!=keyWords && !"".equals(keyWords)){
				
				luceneProject.setKeyWords(keyWords);
			}
			String projectHolder  = projectInfo.get("projectHolder")+"";
			if(null!=projectHolder && !"".equals(projectHolder)){
				
				List<String> protype = new ArrayList<String>();
				String[]proArr = projectHolder.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				luceneProject.setProjectHolder(protype);
			}
			String projectContactId  = projectInfo.get("projectContactId")+"";
			if(null!=projectContactId && !"".equals(projectContactId)){
				
				luceneProject.setProjectContactId(projectContactId);
			}
			String projectContactName  = projectInfo.get("projectContactName")+"";
			if(null!=projectContactName && !"".equals(projectContactName)){
				
				luceneProject.setProjectContactName(projectContactName);
			}
			String technical  = projectInfo.get("technical")+"";
			if(null!=technical && !"".equals(technical)){
				
				luceneProject.setTechnical(getDicSingleWorth(Integer.parseInt(technical), Constant.DICTIONTRY_PROJECTTECHNICAL));
			}
			String projectRequirements  = projectInfo.get("projectRequirements")+"";
			if(null!=projectRequirements && !"".equals(projectRequirements)){
				
				luceneProject.setProjectRequirements(projectRequirements);
			}
			String marketProspect  = projectInfo.get("marketProspect")+"";
			if(null!=marketProspect && !"".equals(marketProspect)){
				
				luceneProject.setMarketProspect(marketProspect);
			}
			String technicalMaturity  = projectInfo.get("technicalMaturity")+"";
			if(null!=technicalMaturity && !"".equals(technicalMaturity)){
				
				luceneProject.setTechnicalMaturity(technicalMaturity);
			}
			  
		}catch(Exception e){
			String technical  = projectInfo.get("technical")+"";
			e.printStackTrace();
			return null;
		}
		return luceneProject;
	}
	
	private LuceneCustomer luceneCustomerConversion(Map<Object,Object> customerInfo){
		LuceneCustomer lc = new LuceneCustomer();
		try{
		
			String customerId = customerInfo.get("customerId")+"";
			if(null!=customerId &&!"".equals(customerId)){
				lc.setCustomerId(customerId);
			}
			String customerNumber = customerInfo.get("customerNumber")+"";
			if(customerNumber!=null&&!"".equals(customerNumber)){
				lc.setCustomerNumber("C"+customerNumber);
			}
			String customerSource =customerInfo.get("customerSource")+"";
			
			if(customerSource!=null&&!"".equals(customerSource)){
				lc.setCustomerSource(getDicSingleWorth(Integer.parseInt(customerSource), Constant.DICTIONTRY_CUSTOMERSOURCE));
			}
			String customerType = customerInfo.get("customerType")+"";
			if(customerType!=null&&!"".equals(customerType)){
				lc.setCustomerType(getDicSingleWorth(Integer.parseInt(customerType), Constant.DICTIONTRY_CUSTOMERTYPE));
			}
			String  researchField =customerInfo.get("researchField")+"";
			if(researchField!=null&&!"".equals(researchField)){
				researchField = getDicCheckboxWorth(researchField, Constant.DICTIONTRY_PROJECTFIELD);
				List<String> protype = new ArrayList<String>();
				String[]proArr = researchField.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				lc.setResearchField(protype);
			}
				
			String area =customerInfo.get("area")+"";
			String domesticOrForeign =customerInfo.get("domesticOrForeign")+"";
			if(area!=null&&!"".equals(area)){
				lc.setArea(getAreaWorth(area, Integer.parseInt(domesticOrForeign)));
			}
			String customerName =customerInfo.get("customerName")+"";
			if(customerName!=null&&!"".equals(customerName)){
				lc.setCustomerName(customerName);
			}
			String	customerNature = customerInfo.get("customerNature")+"";
			if(customerNumber!=null&&!"".equals(customerNumber)){
				lc.setCustomerNature(getDicSingleWorth(Integer.parseInt(customerNature), Constant.DICTIONTRY_CUSTOMERNATURE));
			}
			String mainBusiness = customerInfo.get("mainBusiness")+"";
			if(mainBusiness!=null&&!"".equals(mainBusiness)){
				lc.setMainBusiness(mainBusiness);
			}
			String majorNeeds = customerInfo.get("majorNeeds")+"";
			if(majorNeeds!=null&&!"".equals(majorNeeds)){
				lc.setMajorNeeds(majorNeeds);
			}
			String intentionCooperate2 = customerInfo.get("intentionCooperate2")+"";
			if(intentionCooperate2!=null&&!"".equals(intentionCooperate2)){
				lc.setIntentionCooperate2(getDicSingleWorth(Integer.parseInt(intentionCooperate2), Constant.DICTIONTRY_INTENTIONCOOPERATE2));
			}
			String intentionCooperate = customerInfo.get("intentionCooperate")+"";
			if(intentionCooperate!=null&&!"".equals(intentionCooperate)){
				lc.setIntentionCooperate(getDicSingleWorth(Integer.parseInt(intentionCooperate), Constant.DICTIONTRY_INTENTIONCOOPERATE));
			}
			String currentState = customerInfo.get("currentState")+"";
			if(currentState!=null&&!"".equals(currentState)){
				lc.setCurrentState(getDicSingleWorth(Integer.parseInt(currentState), Constant.DICTIONTRY_CURRENTSATUS));
			}
			String customerContact= customerInfo.get("customerContact")+"";
			if(customerContact!=null&&!"".equals(customerContact)){
				lc.setCustomerContact(customerContact);
			}
			String customerContactName = customerInfo.get("customerContactName")+"";
			if(customerContactName!=null&&!"".equals(customerContactName)){
				lc.setCustomerContactName(customerContactName);
			}
			
		}catch(Exception  e){
			e.printStackTrace();
			return null;
		}
		return lc;
	}
	private LuceneDemand  luceneDemandConversion(Map<Object,Object> info){
		LuceneDemand ld = new LuceneDemand();
		try{
			String demandId = info.get("demandId")+"";
			if(demandId!=null&&!"".equals(demandId)){
				ld.setDemandId(demandId);
			}
			String demandNumber = info.get("demandNumber")+"";
			if(demandNumber!=null&&!"".equals(demandNumber)){
				ld.setDemandNumber("D"+demandNumber);
			}
			String source = info.get("source")+"";
			if(source!=null&&!"".equals(source)){
				ld.setSource(getDicSingleWorth(Integer.parseInt(source), Constant.DICTIONTRY_PROJECTSOURCE));
			}
			String sourceRemark = info.get("sourceRemark")+"";
			if(sourceRemark!=null&&!"".equals(sourceRemark)){
				ld.setSourceRemark(sourceRemark);
			}
			String demandType = info.get("demandType")+"";
			if(demandType!=null&&!"".equals(demandType)){
				demandType= 	getDicCheckboxWorth(demandType, Constant.DICTIONTRY_DEMANDTYPE);
				List<String> protype = new ArrayList<String>();
				String[]proArr = demandType.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				ld.setDemandType(protype);
			}
					
			String researchField = info.get("researchField")+"";
			if(researchField!=null&&!"".equals(researchField)){
				researchField= 	getDicCheckboxWorth(researchField, Constant.DICTIONTRY_DEMANDFIELD);
						
				List<String> protype = new ArrayList<String>();
				String[]proArr = researchField.split(",");
				for(String s:proArr){
					protype.add(s);
				}
				ld.setResearchField(protype);
			}
			String area = info.get("area")+"";
			String domesticOrForeign = info.get("domesticOrForeign")+"";
			if(area!=null&&!"".equals(area)){
				ld.setArea(getAreaWorth(area, Integer.parseInt(domesticOrForeign)));
			}
			String demandName = info.get("demandName")+"";
			if(demandName!=null&&!"".equals(demandName)){
				ld.setDemandName(demandName);
			}
			String demandStatus = info.get("demandStatus")+"";
			if(demandStatus!=null&&!"".equals(demandStatus)){
				ld.setDemandStatus(getDicSingleWorth(Integer.parseInt(demandStatus), Constant.DICTIONTRY_DEMANDSTATUS));
			}
			String demandContent = info.get("demandContent")+"";
			if(demandContent!=null&&!"".equals(demandContent)){
				ld.setDemandContent(demandContent);
			}
			String demandContactId = info.get("demandContactId")+"";
			if(demandContactId!=null&&!"".equals(demandContactId)){
				ld.setDemandContactId(demandContactId);
			}
			String demandContactName = info.get("demandContactName")+"";
			if(demandContactName!=null&&!"".equals(demandContactName)){
				ld.setDemandContactName(demandContactName);
			}
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
		return ld;
	}
	/***
	 * @date 2018-09-13
	 * @author dq
	 * 初始化目标对象的索引
	 * @param tagert 初始化那个对象索引
	 * @param start 从哪个Id开始初始化
	 * @return
	 */
	@RequestMapping("initIndex")
	 @ResponseBody
	public Json initIndex(String tagert,Integer start){
//		IsolrOperation<LuceneDemand> tt = new SolrOperation<LuceneDemand>();
//		tt.queryList(1, 10, 1, "66f6aa26d9414064a90d53eac77af150");
//			if(1==1)return null;
		try{
			if(null==start){
				start=0;
			}
			if(tagert.equals("project")){
				IsolrOperation<LuceneProject> solr = new SolrOperation<LuceneProject>();

				PageHelper.startPage(1, 10000);
				List<Map<Object,Object>>	list = projectService.findProjectByIndex(start);
				PageInfo<Map<Object,Object>> pageInfo = new PageInfo<Map<Object,Object>>(list);
				Integer total = Integer.parseInt(pageInfo.getTotal()+"");
				int page=0;
				if(total>10000){
					//先把前10000条数据加入索引
					List<LuceneProject> listlp= new ArrayList<LuceneProject>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneProject lp =luceneProjectConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("project", listlp);
					page=(int) Math.ceil(total / (double) 10000);
					System.out.println("project------------添加10000条索成功-------------");
					//循环查询所有的数据 每次查1W条数据
					for (int i=2;i<=page;i++) {
						PageHelper.startPage(i, 10000);
						List<Map<Object,Object>>	list1 = projectService.findProjectByIndex(start);
						
						List<LuceneProject> list2= new ArrayList<LuceneProject>();
						for(int k=0;k<list1.size();k++){
							Map<Object,Object> simp = list1.get(k);
							LuceneProject lp =luceneProjectConversion(simp);
							if(null!=lp){
								list2.add(lp);
							}
						}
						solr.add("project", list2);
						 System.out.println("project------------添加10000条索成功-------------");
					}
				}else{
					List<LuceneProject> listlp= new ArrayList<LuceneProject>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneProject lp =luceneProjectConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("project", listlp);
					 System.out.println("project------------添加"+list.size()+"条索成功-------------");
				}
			}else if(tagert.equals("person")){
				IsolrOperation<LucenePerson> solr = new SolrOperation<LucenePerson>();
				PageHelper.startPage(1, 10000);
				List<Person>	list = personService.findPersonByIndex(start);
				PageInfo<Person> pageInfo = new PageInfo<Person>(list);
				Integer total = Integer.parseInt(pageInfo.getTotal()+"");
				int page=0;
				if(total>10000){
					//先把前10000条数据加入索引
					List<LucenePerson> listlp= new ArrayList<LucenePerson>();
					for(int k=0;k<list.size();k++){
						Person simp = list.get(k);
						LucenePerson lp =lucenePersonConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("person", listlp);
					page=(int) Math.ceil(total / (double) 10000);
					System.out.println("pseron------------添加10000条索成功-------------");
					//循环查询所有的数据 每次查1W条数据
					for (int i=2;i<=page;i++) {
						PageHelper.startPage(i, 10000);
						List<Person>	list1 = personService.findPersonByIndex(start);
						List<LucenePerson> list2= new ArrayList<LucenePerson>();
						for(int k=0;k<list1.size();k++){
							Person simp = list1.get(k);
							LucenePerson lp =lucenePersonConversion(simp);
							if(null!=lp){
								list2.add(lp);
							}
						}
						solr.add("person", list2);
						 System.out.println("pseron------------添加10000条索成功-------------");
					}
				}else{
					List<LucenePerson> listlp= new ArrayList<LucenePerson>();
					for(int k=0;k<list.size();k++){
						Person simp = list.get(k);
						LucenePerson lp =lucenePersonConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("person", listlp);
					System.out.println("pseron------------添加"+list.size()+"条索成功-------------");
				}
			}else if(tagert.equals("customer")){ 
				IsolrOperation<LuceneCustomer> solr = new SolrOperation<LuceneCustomer>();

				PageHelper.startPage(1, 10000);
				List<Map<Object,Object>>	list = customerService.findCustomerByIndex(start);
				PageInfo<Map<Object,Object>> pageInfo = new PageInfo<Map<Object,Object>>(list);
				Integer total = Integer.parseInt(pageInfo.getTotal()+"");
				int page=0;
				if(total>10000){
					//先把前10000条数据加入索引
					List<LuceneCustomer> listlp= new ArrayList<LuceneCustomer>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneCustomer lp =luceneCustomerConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("customer", listlp);
					page=(int) Math.ceil(total / (double) 10000);
					System.out.println("customer------------添加10000条索成功-------------");
					//循环查询所有的数据 每次查1W条数据
					for (int i=2;i<=page;i++) {
						PageHelper.startPage(i, 10000);
						List<Map<Object,Object>>	list1 = customerService.findCustomerByIndex(start);
						
						List<LuceneCustomer> list2= new ArrayList<LuceneCustomer>();
						for(int k=0;k<list1.size();k++){
							Map<Object,Object> simp = list1.get(k);
							LuceneCustomer lp =luceneCustomerConversion(simp);
							if(null!=lp){
								list2.add(lp);
							}
						}
						solr.add("customer", list2);
						 System.out.println("customer------------添加10000条索成功-------------");
					}
				}else{
					List<LuceneCustomer> listlp= new ArrayList<LuceneCustomer>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneCustomer lp =luceneCustomerConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("customer", listlp);
					 System.out.println("customer------------添加"+list.size()+"条索成功-------------");
				}
			}else if(tagert.equals("demand")){ 
				IsolrOperation<LuceneDemand> solr = new SolrOperation<LuceneDemand>();

				PageHelper.startPage(1, 10000);
				List<Map<Object,Object>>	list = demandService.findDemandByIndex(start);
				PageInfo<Map<Object,Object>> pageInfo = new PageInfo<Map<Object,Object>>(list);
				Integer total = Integer.parseInt(pageInfo.getTotal()+"");
				int page=0;
				if(total>10000){
					//先把前10000条数据加入索引
					List<LuceneDemand> listlp= new ArrayList<LuceneDemand>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneDemand lp =luceneDemandConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("demand", listlp);
					page=(int) Math.ceil(total / (double) 10000);
					System.out.println("demand------------添加10000条索成功-------------");
					//循环查询所有的数据 每次查1W条数据
					for (int i=2;i<=page;i++) {
						PageHelper.startPage(i, 10000);
						List<Map<Object,Object>>	list1 = demandService.findDemandByIndex(start);
						
						List<LuceneDemand> list2= new ArrayList<LuceneDemand>();
						for(int k=0;k<list1.size();k++){
							Map<Object,Object> simp = list1.get(k);
							LuceneDemand lp =luceneDemandConversion(simp);
							if(null!=lp){
								list2.add(lp);
							}
						}
						solr.add("demand", list2);
						 System.out.println("demand------------添加10000条索成功-------------");
					}
				}else{
					List<LuceneDemand> listlp= new ArrayList<LuceneDemand>();
					for(int k=0;k<list.size();k++){
						Map<Object,Object> simp = list.get(k);
						LuceneDemand lp =luceneDemandConversion(simp);
						if(null!=lp){
							listlp.add(lp);
						}
					}
					solr.add("demand", listlp);
					 System.out.println("demand------------添加"+list.size()+"条索成功-------------");
				}
			}
		}catch(Exception e){
			logger.error(e.getMessage(), e);
		}
		 return new Json(true, "success", "添加索引成功");
	}
}
